﻿using System;

    class ShipDamage
    {
        static void Main()
        {
            int swaper=0;
            short calculator=0;
            int H = int.Parse(Console.ReadLine());
            int Sx1 = int.Parse(Console.ReadLine())+H;
            int Sy1 = int.Parse(Console.ReadLine()) + H;
            int Sx2 = int.Parse(Console.ReadLine()) + H;
            int Sy2 = int.Parse(Console.ReadLine()) + H;
            int Cx1 = int.Parse(Console.ReadLine()) - H;
            int Cy1 = int.Parse(Console.ReadLine()) - H;
            int Cx2 = int.Parse(Console.ReadLine()) - H;
            int Cy2 = int.Parse(Console.ReadLine()) - H;
            int Cx3 = int.Parse(Console.ReadLine()) - H;
            int Cy3 = int.Parse(Console.ReadLine()) - H;
            int insidex = Sx1-(Sx1-Sx2);
            int insidey = Sy1-(Sy1-Sy2);
            if (Sx1 > Sx2)
            {
                swaper = Sx1;
                Sx1 = Sx2;
                Sx2 = swaper;
            }
            if (Sy1 > Sy2)
            {
                swaper = Sy1;
                Sy1 = Sx2;
                Sy2 = swaper;
            }
            if (((Cx3 >= Sx1) && (Cx3 <= Sx2)) || ((Cx2 >= Sx1) && (Cx2 <= Sx2)) || ((Cx1 >= Sx1) && (Cx1 <= Sx2)))
            {
                if (((Cy3 > Sy1) && (Cy3 < Sy2)) || ((Cy2 > Sy1) && (Cy2 < Sy2)) || ((Cy1 > Sy1) && (Cy1 < Sy2)))
                    if ((Cy3 == insidey) || (Cy2 == insidey) || (Cy1 == insidey))
                        calculator += 100;
                    else if ((Cx3 == insidex) || (Cx2 == insidex) || (Cx1 == insidex))
                        calculator += 100;
                    else
                        calculator += 50;
                else if (((Cy3 == Sy1) || (Cy3 == Sy2)) || ((Cy2 == Sy1) || (Cy2 == Sy2)) || ((Cy1 == Sy1) || (Cy1 == Sy2)))
                {
                    calculator += 25;
                }
                Console.WriteLine(calculator);
            }
        }
    }

